package com.menker.app.di;

import android.app.Application;

import com.menker.app.DaggerMyAppComponent;
import com.menker.app.MyAppComponent;
import com.menker.app.di.module.AppModule;
import com.menker.app.ui.generalweb.DaggerGeneralWebViewActivityComponent;
import com.menker.app.ui.generalweb.DaggerGeneralWebViewPresenterComponent;
import com.menker.app.ui.generalweb.DaggerNoRefreshWebViewActivityComponent;
import com.menker.app.ui.generalweb.GeneralWebViewActivityComponent;
import com.menker.app.ui.generalweb.GeneralWebViewPresenterComponent;
import com.menker.app.ui.generalweb.NoRefreshWebViewActivityComponent;
import com.menker.app.ui.main.DaggerMainActivityComponent;
import com.menker.app.ui.main.MainActivityComponent;
import com.menker.app.ui.splash.DaggerSplashActivityComponent;
import com.menker.app.ui.splash.SplashActivityComponent;
import com.menker.app.ui.welcome.DaggerWelcomeActivityComponent;
import com.menker.app.ui.welcome.WelcomeActivityComponent;

/**
 * @author J.Huang
 * @version 1.0
 */

public class Injector {
    private static MyAppComponent mAppComponent = null;

    private Injector() {}
    public static MyAppComponent initMyAppComponent(Application app) {
        mAppComponent = null;
        mAppComponent = DaggerMyAppComponent.builder()
                .appModule(new AppModule(app))
                .build();
        return mAppComponent;
    }

    public static SplashActivityComponent initSplashActivityComponent() {
        SplashActivityComponent component = null;
        if (mAppComponent != null) {
            component = DaggerSplashActivityComponent.builder()
                    .myAppComponent(mAppComponent)
                    .build();
        }
        return component;
    }

    public static MainActivityComponent initMainActivityComponent() {
        MainActivityComponent component = null;
        if (mAppComponent != null) {
            component = DaggerMainActivityComponent.builder()
                    .myAppComponent(mAppComponent)
                    .build();
        }
        return component;
    }

    public static GeneralWebViewActivityComponent initGeneralWebViewActivityComponent() {
        GeneralWebViewActivityComponent component = null;
        if (mAppComponent != null) {
            component = DaggerGeneralWebViewActivityComponent.builder()
                    .myAppComponent(mAppComponent)
                    .build();
        }
        return component;
    }

    public static NoRefreshWebViewActivityComponent initNoRefreshWebViewActivityComponent() {
        NoRefreshWebViewActivityComponent component = null;
        if (mAppComponent != null) {
            component = DaggerNoRefreshWebViewActivityComponent.builder()
                    .myAppComponent(mAppComponent)
                    .build();
        }
        return component;
    }

    public static GeneralWebViewPresenterComponent initGeneralWebViewPresenterComponent() {
        GeneralWebViewPresenterComponent component = null;
        if (mAppComponent != null) {
            component = DaggerGeneralWebViewPresenterComponent.builder()
                    .myAppComponent(mAppComponent)
                    .build();
        }
        return component;
    }

    public static WelcomeActivityComponent initWelcomeActivityComponent() {
        WelcomeActivityComponent component = null;
        if (mAppComponent != null) {
            component = DaggerWelcomeActivityComponent.builder()
                    .myAppComponent(mAppComponent)
                    .build();
        }
        return component;
    }
}
